package com.ebc.eservice.util.excel;

import com.alibaba.excel.EasyExcel;
import com.ebc.eservice.vo.excel.StaffExportExcel;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author: Joey
 * @Description: excel工具
 * @date:2022/10/5 23:32
 */

public class DownloadExcel {

    public static void downloadStaff(HttpServletResponse response, Class t, List list,Integer companyId) throws IOException, IllegalAccessException,InstantiationException {
        response.setContentType("application/vnd.ms-excel");// 设置文本内省
        response.setCharacterEncoding("utf-8");// 设置字符编码
        response.setHeader("Content-disposition", "attachment;filename=staffList-"+companyId+".xlsx"); // 设置响应头
        EasyExcel.write(response.getOutputStream(), t).sheet("员工信息表").doWrite(list); //用io流来写入数据
    }

}
